Glass = Widget.extend({
	ctor:function(parent,action){
		this._super(parent,action);
		this.init();
		if(action==ACTION_DO1){
			this.setTag(TAG_GLASS_ALL);
		}else if(action==ACTION_DO2){
			this.setTag(TAG_GLASS1_ALL);
		}
		
	},
	init:function(){
		this.body = new Button(this, 10, TAG_GLASS, "#Glass rod/right2.png", this.callback,this);
		this.body.setScale(1,1.3);
		
		var right1=new Button(this,10,TAG_RIGHT21,"#Glass rod/right1.png",this.callback,this);
		right1.setPosition(cc.p(0,this.body.height*0.1));
		right1.setVisible(false);

		var right2=new Button(right1,10,TAG_RIGHT22,"#Glass rod/right2.png",this.callback,this);
		right2.setPosition(cc.p(right1.width*0.5, right1.height*0.5));
		right2.setScale(1,1.3);

		var right3=new Button(right1,10,TAG_RIGHT23,"#Glass rod/right3.png",this.callback,this);
		right3.setPosition(cc.p(right1.width*0.5, right1.height*0.5));
	},
	move:function(){
		var ber=cc.bezierBy(1, [cc.p(50,80),cc.p(170,350),cc.p(170,160)]);
		var rotate=cc.rotateBy(1,-5);
		this.body.runAction(cc.sequence(ber,rotate));
	},
	moveback:function(){
		var ber=cc.bezierBy(1, [cc.p(50,80),cc.p(170,350),cc.p(170,160)]);
		var rotate=cc.rotateBy(1,-5);
		this.body.runAction(cc.sequence(rotate.reverse(),ber.reverse()));
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		},this);
		var beaker=ll.run.getChildByTag(TAG_BEAKER_ALL);
		var body=beaker.getChildByTag(TAG_BEAKER);
		var powder=body.getChildByTag(TAG_POWDER);
		var right1=this.getChildByTag(TAG_RIGHT21);
		switch (p.getTag()) {
		case TAG_GLASS:
			var ber=cc.bezierBy(1, [cc.p(-10,30),cc.p(-30,260),cc.p(-118,20)]);
			var seq=cc.sequence(cc.moveBy(0.2, cc.p(20,8)),cc.moveBy(0.2,cc.p(-20, 8)),
					cc.moveBy(0.2,cc.p(-20, -8)),cc.moveBy(0.2,cc.p(20, -8))).repeat(5);
			p.setVisible(false);
			right1.setVisible(true);
			right1.runAction(cc.sequence(ber,cc.spawn(seq,cc.callFunc(function() {
				powder.runAction(cc.fadeOut(2));
			},this)),ber.reverse(),cc.callFunc(function() {
				right1.setVisible(false);
			},this),func));
			break;
		default:
			break;
		}
	}
});